export default {
  circlepoi(start, end) {
    // 起始点 起点 半径
    debugger;
    const { x: startX, y: startY } = start
    const { x: endX, y: endY } = end

    // 两圆圆心坐标连线的长度
    const distance = Math.sqrt(Math.pow(endX - startX, 2) + Math.pow(endY - startY, 2))

    // 弧线所对应的弧度
    // 为确保弧线的弧度不会过大，默认弧线对应的角度为60°
    // 即圆心与两圆圆心连线后为等边三角形，半径就等于两圆圆心坐标的间距
    const arcAngle = Math.PI / 3

    // 两圆圆心坐标连线与x轴夹角所对应的弧度
    const posLineAngle = Math.atan2(endY - startY, endX - startX)

    // 弧线的圆心与起始点坐标连线与X轴夹角所对应的弧度
    const arcLineAngle = arcAngle - posLineAngle

    // 弧线的圆心坐标
    const circle = {
      x: startX + distance * Math.cos(arcLineAngle),
      y: startY - distance * Math.sin(arcLineAngle)
    }
    return circle;
  },
  getCirclePoint(start, circle) {
    // 计算r
    debugger;
    const { x: startX, y: startY } = start;
    const { x: cX, y: cY } = circle;
    let r = Math.sqrt((Math.pow(cX - startX, 2) + Math.pow(cY - startY, 2)));
    var num = 59; // 求60个点
    var points = []
    for (var i = -2; i < num; i++) {
      var hudu = (2 * Math.PI / 360) * i;
      var y = cY + Math.sin(hudu) * r;
      var x = Math.cos(hudu) * r + cX;
      points.push([x, y]);
    }
    return points;
  }
}